package steampunk.geom;

import steampunk.art.*;
import steampunk.utils.Mutil;

public class CircleGeom extends BaseGeom {
	private double radius = 0;
	
	public CircleGeom(double radius) {
		this.radius = radius;
	}
	
	
	/**
	 * Retruns the radius of the circle
	 * @return - double
	 */
	public double r() {
		return radius;
	}
	
	@Override
	public double bottom() {
		return getY() + r();
	}

	@Override
	public void bottom(double d) {
		setY(d-r());
	}
	@Override
	public Art getWireArt() {
		return new CircleArt(this);
	}

	@Override
	public double left() {
		return getX()-r();
	}

	@Override
	public void left(double d) {
			setX(d+r());
	}

	@Override
	public double right() {
		return getX()+r();
	}

	@Override
	public void right(double d) {
		setX(d-r());
	}

	@Override
	public double top() {
		return getY()-r();
	}

	@Override
	public void top(double d) {
		setY(d+r());
	}

	@Override
	public boolean containsPoint(double x, double y) {
		return Mutil.within(getX(), getY(), x, y, r());
	}

	@Override
	public boolean intersects(Intersectable other) {
		return other.intersectsCircle(getX(), getY(), r());
	}

	@Override
	public boolean intersectsCircle(double x, double y, double radius) {
		return Mutil.within(getX(), getY(), x, y, r()+radius);
	}

	@Override
	public boolean intersectsLine(double x1, double y1, double x2, double y2) {
		return Mutil.intLineCircle(x1, y1, x2, y2, getX(), getY(), r());
	}

	@Override
	public boolean intersectsRect(int x, int y, int w, int h) {
		return Mutil.intRectCircle(x, y, w, h, getX(), getY(), r());
	}

}
